package com.my.springBoot.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.my.springBoot.annotation.Log;
import com.my.springBoot.system.controller.BaseController;
import com.my.springBoot.system.model.AjaxResult;
import com.my.springBoot.enums.BusinessType;
import com.my.springBoot.business.domain.ComplaintType;
import com.my.springBoot.business.service.IComplaintTypeService;
import com.my.springBoot.utils.poi.ExcelUtil;
import com.my.springBoot.page.TableDataInfo;

/**
 * 投诉类型Controller
 * 
 * @author ${author}
 * @date 2024-01-13
 */
@RestController
@RequestMapping("/business/complaintType")
public class ComplaintTypeController extends BaseController
{
    @Autowired
    private IComplaintTypeService complaintTypeService;

    /**
     * 查询投诉类型列表
     */
    @PreAuthorize("@ss.hasPermi('business:complaintType:list')")
    @GetMapping("/list")
    public TableDataInfo list(ComplaintType complaintType)
    {
        startPage();
        List<ComplaintType> list = complaintTypeService.selectComplaintTypeList(complaintType);
        return getDataTable(list);
    }

    /**
     * 导出投诉类型列表
     */
    @PreAuthorize("@ss.hasPermi('business:complaintType:export')")
    @Log(title = "投诉类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ComplaintType complaintType)
    {
        List<ComplaintType> list = complaintTypeService.selectComplaintTypeList(complaintType);
        ExcelUtil<ComplaintType> util = new ExcelUtil<ComplaintType>(ComplaintType.class);
        util.exportExcel(response, list, "投诉类型数据");
    }

    /**
     * 获取投诉类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:complaintType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(complaintTypeService.selectComplaintTypeById(id));
    }

    /**
     * 新增投诉类型
     */
    @PreAuthorize("@ss.hasPermi('business:complaintType:add')")
    @Log(title = "投诉类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ComplaintType complaintType)
    {
        return toAjax(complaintTypeService.insertComplaintType(complaintType));
    }

    /**
     * 修改投诉类型
     */
    @PreAuthorize("@ss.hasPermi('business:complaintType:edit')")
    @Log(title = "投诉类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ComplaintType complaintType)
    {
        return toAjax(complaintTypeService.updateComplaintType(complaintType));
    }

    /**
     * 删除投诉类型
     */
    @PreAuthorize("@ss.hasPermi('business:complaintType:remove')")
    @Log(title = "投诉类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(complaintTypeService.deleteComplaintTypeByIds(ids));
    }
}
